class ConditionController < ApplicationController

  def add
    @condition = Condition.new
  end

  def create
    #create our condition
     @condition = Condition.new(params[:condition])
   
    if @condition.save #== @user
      flash[:notice] = 'Thanks'
      redirect_to :controller => "condition", :action => "index"
    else
      flash[:notice] = 'Problem detected'
      render :action => "add"
    end
  end

  def edit
    @condition = Condition.find(params[:id])
  end

  def update
    @condition = Condition.find(params[:id])
    
    if @condition.update_attributes(params[:condition])
      flash[:notice] = 'Updated'
      redirect_to :action => "index"
    else
      render :action => "edit"
    end
  end

  def index
    @conditions = Condition.find :all
  end

  def delete
  end

  def destroy
    if  Condition.destroy(params[:id])
      flash[:notice] = 'Deleted'
      redirect_to :action => "index"
    else
      render :action => "edit"
    end
  end
end
